using SurveySez.Model;
using SurveySez.NavigationModel;

namespace SurveySez.ViewModel.GamePlay
{
	public class AnswerViewModel
	{
		private Response _answer;
		private GameNavigation _navigation;

		private AnswerViewModel(Response answer, GameNavigation navigation)
		{
			_answer = answer;
			_navigation = navigation;
		}

		public string Response
		{
			get { return _answer.Answer; }
		}

		public bool IsGuessed
		{
			get { return _navigation.CurrentRound.IsAnswerGuessed(_answer); }
		}

		public override bool Equals(object obj)
		{
			if (obj == this)
				return true;
			AnswerViewModel that = obj as AnswerViewModel;
			if (that == null)
				return false;

			return object.Equals(this._answer, that._answer);
		}

		public override int GetHashCode()
		{
			return _answer.GetHashCode();
		}

		public static AnswerViewModel Wrap(Response answer, GameNavigation navigation)
		{
			if (answer == null)
				return null;
			else
				return new AnswerViewModel(answer, navigation);
		}

		public static Response Unwrap(AnswerViewModel viewModel)
		{
			if (viewModel == null)
				return null;
			else
				return viewModel._answer;
		}
	}
}
